package foliotracker.GUI;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JTextField;

import foliotracker.controllers.PortfolioCollectionController;


public class NewPortfolioDialog extends DialogBase
{
	private JTextField field;
	private PortfolioCollectionController controller;
	
	public NewPortfolioDialog(PortfolioCollectionController controller)
	{
		super("New portfolio");
		
		this.controller = controller;
		
		panel.setLayout(new BorderLayout());
		
		JLabel label = new JLabel("Please enter a name:");
		panel.add(label, BorderLayout.NORTH);
		
		field = new JTextField();
		panel.add(field, BorderLayout.SOUTH);
		
		this.setSize(240, 120);
		setPosition();
	}

	@Override
	protected void okButton_Clicked()
	{
		//TODO: check for empty name
		controller.addPortfolio(field.getText());
		super.setVisible(false);
	}

	@Override
	protected void cancelButton_Clicked()
	{
		super.setVisible(false);
	}
}
